<%@ page contentType="text/html; charset=utf-8" language="java"
	import="java.sql.*" 
	import="java.util.*"
	import= "ass.beans.*"
	import= "ass.dao.*"
	import= "ass.dao.support.*"
	import= "java.text.SimpleDateFormat"
	import= "java.text.ParseException"
	errorPage=""
	
	%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Welcome</title>
<script type="text/javascript">
function validateForm()
{
	
var error="Error:\n"; 
var a=document.forms["myform1"]["username"].value;
var b=document.forms["myform1"]["password"].value;

if (a==null || a==""||a=="Username")
  {
  error=error+"Please input username\n";
  }
if (b==null || b==""||b=="password")
{
  error=error+"Please input password\n";
}
  
  
  if (error!="Error:\n"){
	  alert(error);
	  return false;
  }
}
</script>


<style type="text/css">
div.divLogin {
	position: relative;
	top: 0;
	left: 0;
	width: 200px;
	height: 130px;
}

div.divRight1 {
	position: relative;
	left: 200px;
	top: -130px;
	width: 200px;
	height: 1000px;
}

div.divRight2 {
	position: relative;
	left: 400px;
	top: -1130px;
	width: 200px;
}
</style>

</head>

<body>
	<%@ include file="header.html"%>

	
	<div class="divLogin" align="left">
		<form name="myform1" method="get" action="LoginServlet" onsubmit="return validateForm();">
		
		
		
		<%= (String) request.getAttribute("email_confirm") == null ? "":(String) request.getAttribute("email_confirm") %>
	    <%= (String) request.getAttribute("invalid_password") == null ? "":(String) request.getAttribute("invalid_password") %>
		<%= (String) request.getAttribute("logout") == null ? "":(String) request.getAttribute("logout") %>
		
		<% 	List<MovieBean> movieBeanList = new ArrayList<MovieBean>();
			List<MovieBean> movieComingSoonBeanList = new ArrayList<MovieBean>();
		   	MovieDAO movieDAO = new MovieDAOImpl();
		   	SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
		   	
		   	String date ="";
		    date = formatter.format(new java.util.Date());
		
			movieBeanList = movieDAO.getMovieByRangeDate(date , date);
			movieComingSoonBeanList =  movieDAO.getMovieComingSoon(date);
		%>
		
		
		
			<table width="200" border="0">
				<tr>
					
					<td><input name="username" type="text" value="Username"
						id="username" size="15"
						onFocus="document.myform1.username.value=''" />
					</td>
				</tr>
				<tr>

					<td><input name="password" type="password" value="password"
						id="password" size="15"
						onFocus="document.myform1.password.value=''" />
					</td>
				</tr>
				<tr>
					<td><input type="submit" name="Submit" id="button"
						value="Login" />
					</td>

				</tr>

				<tr>
					<td>Not member yet?</td>
				</tr>
				<tr>
					<td>Click <a href="register.jsp">here</a> to register.</td>
				</tr>
			</table>

		</form>

	</div>

	<div class="divRight1">
		<table width="200" border="1">
			<tr>
				<td align="center">Now showing</td>
			</tr>
			
			<% 
				for (MovieBean movieBean : movieBeanList){
					out.print("<tr>" +
							  "<td> title = "+ movieBean.getMovie_title() + "<br/>" +
							  		"preview = "+ "" + "<br/>" +
							  		"main actor = "+ movieBean.getMovie_actor() + "<br/>" +
							  		"synopsis = "+ movieBean.getMovie_synopsis() + "<br/>" +
							  		"rating = "+ movieBean.getMovie_rating() + "<br/>" +
							  "</td>"+
							  "</tr>");
				}
			
			%>
	
		</table>
	</div>
	<div class="divRight2">
		<table width="200" border="1">
			<tr>
				<td align="center">Coming Soon</td>
			</tr>
			<% 
				for (MovieBean movieBean : movieComingSoonBeanList){
					out.print("<tr>" +
							  "<td> title = "+ movieBean.getMovie_title() + "<br/>" +
							  		"preview = "+ "" + "<br/>" +
							  		"main actor = "+ movieBean.getMovie_actor() + "<br/>" +
							  		"synopsis = "+ movieBean.getMovie_synopsis() + "<br/>" +
							  		"rating = "+ movieBean.getMovie_rating() + "<br/>" +
							  "</td>"+
							  "</tr>");
				}
			
			%>
		</table>

	</div>

</body>
</html>